package com.project.controller;

import com.project.bean.SpeakBean;
import com.project.bean.UserBean;
import com.project.service.ISpeakService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("speak")
public class SpeakController {
    @Autowired
    private ISpeakService speakService;
    @RequestMapping("add")
    public String add(SpeakBean speak, HttpServletRequest request){
        //得到登陆用户
        UserBean user = (UserBean)request.getSession().getAttribute("loginUser");
        //在评论对象中添加评论人ID
        speak.setUserId(user.getId());
        //调用业务方法完成添加
        speakService.add(speak);

        return "ok";
    }
}
